# -*- encoding=utf8 -*-
"""
RedFlag-TC000098   （拍摄进入装饰页）剪辑音量功能
调节音量场景
点击视频收起音量工具栏场景
"""
__author__ = "ldm"

import sys
import os

# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)

from PageFunction import CameraVideoShooter
from elements import *

auto_setup(__file__)
shooter = CameraVideoShooter()

log("--------------------------------调节音量场景--------------------------------------")
"""
拍摄进入装饰页
点击剪辑
点击音量
获取初始音量值
点击调整音量
点击取消
点击音量
获取取消调整音量的值
断言
点击音量
点击调整音量
点击确认
点击音量
获取调节后的音量值
断言
"""
shooter.enter_photography_decoration_page()
shooter.click_element(edit_button)
sleep(1.0)
shooter.click_element(edit_volume)
ole_volume_text = shooter.get_element_text(edit_volume_text)
touch((0.30,0.89))
shooter.click_element(edit_volume_cancel)
shooter.click_element(edit_volume)
new_volume_text1 = shooter.get_element_text(poco("cn.migu.video.clip.walle:id/voiceProgressTV"))
shooter.assert_texts_equal(ole_volume_text, new_volume_text1, "断言失败，两个值不相等，修改成功")
shooter.click_element(edit_volume)
touch((0.70,0.89))
shooter.click_element(edit_volume_confirm)
shooter.click_element(edit_volume)
new_volume_text2 = shooter.get_element_text(poco("cn.migu.video.clip.walle:id/voiceProgressTV"))
shooter.assert_compare(ole_volume_text, new_volume_text2, "lt", "断言失败，初始值没有小于调整后的值")
shooter.click_element(edit_volume_confirm)

log("--------------------------------点击视频收起音量工具栏场景--------------------------------------")
"""
点击音量
点击视频空白处
断言
"""
shooter.click_element(edit_volume)
touch((0.5,0.5))
shooter.assert_element_not_exists(poco("cn.migu.video.clip.walle:id/voiceTitle"), "断言失败，并未取消掉音量工具栏")

# 关闭应用
stop_app(UGC_package_name)